package com.demo2do.fms.admin.service.report.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.demo2do.core.entity.page.Page;
import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.fms.admin.entity.search.report.CostRevenueAnalysisSearch;
import com.demo2do.fms.admin.service.report.CostRevenueService;
import com.demo2do.fms.entity.report.CostRevenueAnalysis;

/**
 * 
 * @author Ysy
 *
 */
@Service("costRevenueService")
public class CostRevenueServiceImpl implements CostRevenueService {
	
	@Value("#{config['shipment.electronic.url']}")
	private String electronicUrl;
    
    //private static final Logger logger = LoggerFactory.getLogger(CostRevenueServiceImpl.class);
	
    @Autowired
    private GenericDaoSupport genericDaoSupport;
    
    /* (non-Javadoc)
     * @see com.demo2do.fms.admin.service.business.ShipmentService#countShipment(com.demo2do.fms.admin.entity.search.business.ShipmentSearch)
     */
	@Override
	public int countCostRevenue(CostRevenueAnalysisSearch costRevenueAnalysisSearch) {
		String costSentence = costRevenueAnalysisSearch.buildSentenceTemplate();
		Map<String, Object> costParameters = costRevenueAnalysisSearch.buildParameters();
		return genericDaoSupport.count(costSentence, costParameters);
	}
	/* (non-Javadoc)
     * @see com.demo2do.fms.admin.service.business.ShipmentService#countShipment(com.demo2do.fms.admin.entity.search.business.ShipmentSearch)
     */
	@SuppressWarnings("unchecked")
	public List<CostRevenueAnalysis> listCostRevenueAnalysis(CostRevenueAnalysisSearch costRevenueAnalysisSearch,
			Page page) {
		String buildSentenceTemplate = costRevenueAnalysisSearch.buildSentenceTemplate();
		Map<String, Object> buildParameters = costRevenueAnalysisSearch.buildParameters();
		List<CostRevenueAnalysis>  costRevnueAnalysis = genericDaoSupport.searchForList(buildSentenceTemplate, buildParameters, page.getBeginIndex(), page.getEveryPage());
		page.calculate();
		return costRevnueAnalysis;
	}
	/* (non-Javadoc)
	 * @see com.demo2do.fms.admin.service.business.ShipmentService#countShipment(com.demo2do.fms.admin.entity.search.business.ShipmentSearch)
	 */
	@SuppressWarnings("unchecked")
	public List<CostRevenueAnalysis> listCostRevenueAnalysisAll(CostRevenueAnalysisSearch costRevenueAnalysisSearch) {
		String sentence = costRevenueAnalysisSearch.buildSentenceTemplate();
		Map<String, Object> parameters = costRevenueAnalysisSearch.buildParameters();
		List<CostRevenueAnalysis>  costRevnueAnalysis = genericDaoSupport.searchForCacheableList(sentence, parameters);
		return costRevnueAnalysis;
	}

    
}